home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / lang / pcq12src.lzh / Runtime / Readers / readln.asm < prev    next >
Assembly Source File  |  1990-12-10  |  830b  |  44 lines

  1.  
  2. *    ReadLn.asm (of PCQ Pascal runtime library)
  3. *    Copyright (c) 1989 Patrick Quaid
  4.  
  5. *    Implements readln....
  6.  
  7. *    Algorithm:
  8. *
  9. *    repeat
  10. *        c := the current character
  11. *        eat that character
  12. *    until c = linefeed or EOF
  13. *
  14.  
  15. *    Upon entry, the top of the stack has the file rec address
  16.  
  17.     INCLUDE    "/FileRec.i"
  18.  
  19.     SECTION    PCQ_Runtime,CODE
  20.  
  21.     XREF    _p%ReadOneChar
  22.     XREF    _p%GetThatChar
  23.     XREF    _p%IOResult
  24.  
  25.     XDEF    _p%ReadLn
  26. _p%ReadLn
  27.  
  28.     tst.l    _p%IOResult        ; is IO system intact?
  29.     bne.s    2$
  30.     move.l    4(sp),a0        ; get the file record
  31. 1$    tst.b    EOF(a0)            ; are we at EOF?
  32.     bne.s    2$            ; if so, leave
  33.     jsr    _p%ReadOneChar        ; get the character
  34.     move.w    d0,-(sp)        ; save it
  35.     jsr    _p%GetThatChar        ; eat it
  36.     move.w    (sp)+,d0        ; get it back
  37.     tst.l    _p%IOResult        ; test IO integrity
  38.     bne.s    2$
  39.     cmp.b    #10,d0            ; is it a linefeed?
  40.     bne    1$            ; if not, loop
  41. 2$    rts
  42.  
  43.     END
  44.